package com.ushine.design.design.b_structural_type.e_facade.b_example;

import java.io.FileInputStream;

/**
 * 文件读取类  充当子系统
 *
 * @author yls
 */
public class FileReader {
    public String read(String fileNameSrc) {
        System.out.print("读取文件，获取明文：");
        StringBuffer buf = new StringBuffer();
        try {
            FileInputStream inputStream = new FileInputStream(fileNameSrc);
            int data;
            while ((data = inputStream.read()) != -1) {
                buf = buf.append((char) data);
            }
            inputStream.close();
            System.out.println(buf.toString());
        } catch (Exception e) {
            System.out.println("出现异常");
        }
        return buf.toString();
    }
}
